import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Films from '../views/Films/Films.vue'
//Home同步路由  页面初次加载会将所有的模块进行加载
//About异步路由 可以减少首屏渲染的速度
import City from '../views/City.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/city'
  },
  {
    path:'/city',
    name:'City',
    component:City,//进入f12控制台network不会加载about.js
    meta:{
      isNav:true
    }
  },
  /* 异步路由相关的信息是打印不到的，从city界面可以看到，回到home就看不到了 */
  {
    path: '/center',
    name: 'Center',
    component: () => import('../views/Center/Center.vue')
  },
  {
    path:'/films',
    name:'Films',
    // component:()=>import('../views/Films/Films.vue'),
    component :Films,
    children:[
      {
        path:"nowPlaying",
        component:()=>import('../views/Films/NowPlaying.vue')
      },
      {
        path:"comingSoon",
        component:()=>import('../views/Films/ComingSoon.vue')
      },
    ]
  },
  {
    path: '/film/:id',
    name: 'Film',
    component: () => import('../views/Film/Film.vue'),
  },

  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/*',
    name: 'Error',
    component: () => import('../views/Error.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
